# from views.weixin import _weixin
from views import dingding as dt
import schedule
import time
import requests
import datetime
from .tieba import tieba

# wx = _weixin()



def sendToMe(msg):
    # wx.wxsend(msg, '1')
    dt.send(msg)


def task1():
    url = "http://wap.10010hb.net/weixin/sign/new/doSign.json"
    cookies = [        'wxname=95E84ADB30F4655D533A265C5285CEB7CE4072EA69A52A7CA0704EFA35A7D3DED5920E7C0502A3BA01675FDA45FC3D705AE6EF4BC1C24550157A50B13916447D9BF00DAA471BD64280F356E637867315766254CF8387724A4388FDA0EC7BB28258E81CC46D7E761538944C72D54EFA9172B10E360ECBB85116825975AED1417178F1E69FC25BBD2AB5AAD3C94AD24395ABCC22DA62B286D42238CE6A40FDEED3DB592A6A181588AA460A1FEA4425E88A870D15A0B39D325C313D26C3E02983284379BDBA7105EBC80EC730BE3CA58499651273DE9F265525FE4B3DB024E62CDE156F6F5A2187D0FF700F04A9699BA3203DE9B6E5CB372BB4C4E2BBB66CA6241F4E04FFC1ED3B8062CFC8B148F1CB044D302D4DE090FF25BD3E3E2F2E553A5429E9C3C3EF1ED74CB47BA69997021B852D7B39DBB7C45BF4E32A157B1BAC5B88B953C841C5D96E49EC84FCF55B70A7BBC32D4037B13AE86AA05A0EEA0DBB68863E0058C0A965ADACCA2BD765DCA0AFDF4A6A1FFDC3C96DD0E9AEE04611AE1B825EB4F7BB282AD47F9E517F89D8B0BDD94ACCE7B9E62AA3A7348CA5F2EA1BB0527A98C770CB3329BA13B4C81C3A836244BAAB363C02100074EBEB12D65F0CEC8A4DF8C75DB5F85E7F1774595FFC5F28573979D2E84771360D74DC3BD295B1934160C26047416F1E25947150AE70DEC4EDC099C7F4F3D14A9A045159145222E92F215C7DA883B9E2906976A476C7F088FFA592DCEFF355E2E3C9BEB5D4484B9F06067C89EAFEB369BC4398628479B3495632A9E890EEF90CAE03825E812361AD155D19FFF4A49BAEC8BD5F06F27FCC5D55C5B78D574D90E41050372B7699BF3BB459043E4D94B3586330CFA5B56E81D85507E4C2A770FA434EE2AFCC5650D1E67EF7; uname=BC4F9AAF0D8CB0BAB60E132F3534259980769595904782F43D8C51BFC22C27540F4030582DED9D0436F4D15949351EDC99371B0489C2F6980961E5DCCEB867B8AA5AD9740D700A1DD1BC6A7B942C4EF0D814C1865681BAC62780A892C489311E52AC7F96C60941B66A51E8294A90A9D0B6E6FCDA1FB78C5839D6FCE11F676D4C27E6875F260CF6F39EADCAC73C15CA3DFBC967BAE612AB18B3E70718DDE9788965F81ADC0F50C03F48B3F5698AEEF1109E4FDA10A149403B7179BE97C374A0702981E72F51C31297A548D4376B5C15C1007CC4BC8674FDFBE2FBF25DDBC902F6479BC1F9DD7D95C77B57D7BD07A1A6076B00040AEC88DF7A42B57E8E79D7D047EBBAE6A04A0B8B15AF444EBB3BE42CB2DD26AB8BF9D100048E171E5B40C17C015F5D59478657C5EC7158C4A937970076F5AEB72F30017CC35CBF3BA5B82AEDA0670C5855398F0A7167F3558919CE4BB8A313AA29C6332338A5B8070733DF094F7E69CDC503AC35AF570F1977EB92492C8F3CCEEB614D71B2ACAE069E8870C4986787C9DBC7948D2754D4DA6EA9A99C342D4A1AB08B6A04585EB346CEE034B1CFD060491AFF1DCC043A6DDBFCBAB8252E8AF987E9ECBBAEAE7C3AF72626EF6DB54B2875DB8F20369D1898FCCE40C48851BF78A02B9124A2776562B44C448AA1C443333E82A5CDEA8835581853F50756478EBE078BC357EFCDF2CBDB703CFB1A4A734FCD1780385BFC12B134E34998E0CBC622F2BD22235EDE3821B3429CD158FCBB21C26B9D2096E997B0739CF492DAB1B599ECC87B9692DDBE14F99B27518133F4F8148529E282FC8EDFE75542A6003742106DD627257A7B5CEA8AC21BDC43C05262528402162FE88A074D62157D2CE462B60180ECB57C7A092BB1E60646D67C188752742CCFBC8027C28487B8CEBCC1AAEDCA1B033D1A62C88F8C4FF83383892A44E4AD289E597043086116B923576DEE4BC75199762AA6A14258D6117AB23DB0F69C1CF0277EA4C747A48311506D48865DCDE0DE21E320A9F1E5663C4ED91CF9779F9E171BB9BC8D12DD6332FF82CC0AC2E18CB4902FD49F3CADFC9F17CD5D485E5AA40EB35B9023C44CC31D8BDA94DD6933587BED34C37D56A3BC9EEB02B307F11CCDDB36DA61E8888BA24E2FF1FB86B5496B50F50B7DD5679A02A6005795F445231CBA87047F706F2AC0D4B89F2A','uname=4499671EEFE1309B2B0F9D58810C17D2F4B5CD7E25A6ECF2522B765312F238DC03CFA6CB0221E9C81AC98ED431959BC39A40AD821D74CEF1A08A0D277728DD4AAA5AD9740D700A1DD1BC6A7B942C4EF0D814C1865681BAC62780A892C489311E52AC7F96C60941B66A51E8294A90A9D0B6E6FCDA1FB78C5839D6FCE11F676D4C27E6875F260CF6F39EADCAC73C15CA3D3E5FCC328AC4EB1ACDA14BF2B4AD0935DCA260DF3ABE3133443CC7336004C901C62195B78BBD41169C826F47E46DBCAFAB5C239C866E0A73F80655ADBCA18AA7007CC4BC8674FDFBE2FBF25DDBC902F67D0478A937DF65AC1CE5C8392FF4E0BED08C78A8C30AF21DE136E8382327281D6E1247008B77C015A5C429891B5A9109966C7FF3CC4DE2468DC8DBE77BE0F6265533C87D60E12E49956CD7F8BB4C339E9AE487B682BC3A97C45DED959E32F9AC1E228307AE96CE708892DCBF3B70D45FCF5FA3796E18BA16A1C567388765251B4C33F6008B590E82B8D9E977CE7850C801C9972DA43453659FE3C3BF7C743171D84AD88CE7E1E49FC086A1374A03FFCEE2915D697964507047761309107C3838B6B450B2302997B1B8DFEB6B348B929EA9EF9974A51357F034E2BCFF18E910A6D8B1C2CDF338EF5BB76672F69906A0CD4B2875DB8F20369D1898FCCE40C48851F770E3E0251729A4F1333370F54A98D915B0B73FF828B7BB1B67F88B466D0BC8DAAF7C8E4F245C66F1F7140F6EF75A18F83D09251B20D0B7AA9C9859782FA349E5E08F758982E1B53F48B7EB1981732F025E62E77133476C0A19991CF79FE004BA2C4B39CEE0275A179B1A5E71DEA52DD2EE0D63BD68C87367E5C940D991A68342106DD627257A7B5CEA8AC21BDC43C0F7306603BC7582F78F91BFE52A08BC821981C90E42C0C1FA2DA9D4FA92A4B4411A4BAF7C55648AA61CCE358E6BC3C3221A9F3FB03440CEEA5DD2D782FEB315D5E67716FF90B9005630F031D924ABF0909B92D76164C69362238EB04DF020E825B9095F4001F26D3C51D76F4BE698AC45E8F9ECE254B2B99ECC98A7D2A94A69FAFF724C553BB101A92AE9B2FDCD3F58BFBFE47729CC47466781A1514672548656485E5AA40EB35B9023C44CC31D8BDA94DD6933587BED34C37D56A3BC9EEB02B379EF77D3A85B355B6C27FD3DEA8D5887BC16DFB4367108AC9314D3BCECA1B2F0BEB4A8AE018A8BBAE49FDCA61462ED5B; wxname=95E84ADB30F4655D533A265C5285CEB737490087FF844F2B087A907CB8C4059FC6248A1F9F29DF2AF4B41A3CFCAACD1B5AE6EF4BC1C24550157A50B13916447D2EEF007AA18E1BC777A9B332E15D69032FF12621EFA7D64E4496DDC8E9A30D0C1E58B0817F2D5C29AFFD9B9298FE4C37817E725F287E515D7B39965D51EBD83BCA4ABA14B76BC9ED4E0E4EC2052DDB6047E6982D4266745B79564EBD0864D49FDBD36DE752DAA619819A4B1199BFE8541AF50F94BEEFDBEE6EE19CF047F9BE5A3BDDC5FA9AAE618A6A10ACC18ECC202C5ADD9591592346160D20D6DB69D58935D12833F5D7445B9D2528159C86583EEC156F6F5A2187D0FF700F04A9699BA3203DE9B6E5CB372BB4C4E2BBB66CA6241F9F809A99A37615FEA2CF197CB26BC2B3CC449743782F4D2FBF54D3E25A5A45B427A9E26A86F09B3D0D304AA7C8F77C8EDF6B0C825518D08D1F1802921069412DBC5A2BB076551A5D290CCB6625B5FE980995F80A04AB895D94373676B438BE9A9F5B447DCFF8615B1377AC283475BF7D6A1FFDC3C96DD0E9AEE04611AE1B825EB4F7BB282AD47F9E517F89D8B0BDD94AEEBEE71C483ADC03A270C30F806481CC0A35FA71CD9C845BD46022F96D7CD5CF0F731A9CF2A44C569A56F24142DAF1C2CE73A351621E938F47019AFC004481571DEFB69914E9DEA60C170F1D55EF2223BC05E864A91D1513B38EC7FF3997B3C250949E14DF22227089EEA97C1084BF117BA9CCF000BE2283803440DADEC6784A267BAAB68422644732B32E9B1635A6C852E11E1115163DD0FA9C728F4B6B3F47A9E890EEF90CAE03825E812361AD155D19FFF4A49BAEC8BD5F06F27FCC5D55C5110EB5E5E64FC6553BCD0EDD16A5BA397F689CF15309EC06B543DF685B676093E4C2A770FA434EE2AFCC5650D1E67EF7'
    ]
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0_1 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Mobile/15A402 MicroMessenger/6.6.3 NetType/4G Language/zh_CN',
        'Host': 'wap.10010hb.net',
        'Referer': 'http://wap.10010hb.net/weixin/sign/new/index.html?code=011OP3Zp0tiO7q1aQ31q0TGlZp0OP3Zj&state=1',

    }
    data = {
        'signType': 0,
        'signDate': datetime.date.today()
        # 'signDate':'2018-11-04'
    }
    for i in cookies:
        headers['Cookie'] = i
        content = requests.post(url, headers=headers, data=data)
        cx = content.content.decode()
        sendToMe(cx)
        time.sleep(5)

tb = tieba()
def task2():
    sendToMe("开始百度签到")
    tb.run()
    str = "\n".join(tb.ret)
    time.sleep(2)
    sendToMe(str)




def run(id):
    if id == 1:
        schedule.every().day.at("07:05").do(task1)
        schedule.every().day.at("07:19").do(task2)
        while True:
            schedule.run_pending()
            time.sleep(1)
